package org.csmzxy.class2333;

public class Examplenum {
    public static void main(String[] args){
        int[] arr{1, 13, 2, 3, 8};

        for(int i=0; i<arr.length-1;i++){
            if(arr[i]>arr[i+1]){
                int tmp = arr[i];
                arr[i] = arr[i+1];
                arr[i+1] = tmp;
            }
        }
        System.out.println(arr[arr.length-1]);
        int max =arr[0];
        for(int i=0; i<arr.length; i++){
            if(arr[i]>max){
                max = arr[i];
            }
        }
        boolean swapped;
        for (int i = 0; i < arr.length - 1; i++) {
            swapped = false;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                    swapped = true;
                }
            }
            if (!swapped) break; // 提前退出
        }
        System.out.println("最大值:" + max);
    }
}
